package com.cloud.service;

import com.cloud.entity.SysLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Component
public class LogSendFeignContain  {

    //全局list，消费者相当于多线程，当达到一定数量批量插入
    public static List<SysLog> syslogs = null;

    //发送消费者的时间
    public static Long starTime;

    @PostConstruct
    public void initThread() {
        syslogs = new ArrayList<>();
        starTime = System.currentTimeMillis();
    }

    public void sendLog(SysLog sysLog) {
        synchronized (LogSendFeignContain.class) {
            syslogs.add(sysLog);
        }
    }

}
